You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add smooth scrolling to agent component containers
Auto-scroll to bottom when adding new items
Improve user experience in agent configuration forms
Diagram Walkthrough
flowchart LR
A["User clicks Add button"] --> B["New item added to list"]
B --> C["scrollToBottom() function called"]
C --> D["Container scrolls smoothly to bottom"]
Ensure the scroll runs after the DOM has actually rendered the newly added item. Consider using Svelte's tick() (or afterUpdate) instead of setTimeout to guarantee timing and avoid potential race conditions.
function scrollToBottom() {
if (scrollContainer) {
setTimeout(() => {
scrollContainer.scrollTo({
top: scrollContainer.scrollHeight,
behavior: 'smooth'
});
}, 0);
}
}
The scroll is triggered immediately after updating the list; if subsequent updates occur in handleAgentChange(), the final height may change after the scheduled scroll. Consider awaiting a DOM flush before scrolling, or triggering scroll in a reactive block based on list length.
The same scrollToBottom() implementation appears in multiple components. Consider extracting a shared utility or a Svelte action to reduce duplication and keep behavior consistent.
function scrollToBottom() {
if (scrollContainer) {
setTimeout(() => {
scrollContainer.scrollTo({
top: scrollContainer.scrollHeight,
behavior: 'smooth'
});
}, 0);
}
}
Re-check the container inside the async callback and use requestAnimationFrame to run after the next paint. This avoids errors if the component unmounts before the timeout fires and ensures the DOM has rendered before scrolling.
function scrollToBottom() {
- if (scrollContainer) {- setTimeout(() => {- scrollContainer.scrollTo({- top: scrollContainer.scrollHeight,- behavior: 'smooth'- });- }, 0);- }+ // Run after the next paint to ensure DOM/layout is ready+ requestAnimationFrame(() => {+ if (!scrollContainer) return;+ scrollContainer.scrollTo({+ top: scrollContainer.scrollHeight,+ behavior: 'smooth'+ });+ });
}
Apply / Chat
Suggestion importance[1-10]: 6
__
Why: The suggestion correctly proposes using requestAnimationFrame which is better suited for DOM manipulations like scrolling, and it adds a safety check inside the callback, making the code more robust against edge cases.
Low
More
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Enhancement
Description
Add smooth scrolling to agent component containers
Auto-scroll to bottom when adding new items
Improve user experience in agent configuration forms
Diagram Walkthrough
File Walkthrough
agent-knowledge-base.svelte
Add scrolling to knowledge base componentsrc/routes/page/agent/[agentId]/agent-components/agent-knowledge-base.svelte
scrollContainervariable for DOM referencescrollToBottom()function with smooth scrollingscrollToBottom()when adding new knowledge baseagent-mcp-tool.svelte
Add scrolling to MCP tool componentsrc/routes/page/agent/[agentId]/agent-components/agent-mcp-tool.svelte
scrollContainervariable for DOM referencescrollToBottom()function with smooth scrollingscrollToBottom()when adding new MCP toolagent-rule.svelte
Add scrolling to agent rule componentsrc/routes/page/agent/[agentId]/agent-components/agent-rule.svelte
scrollContainervariable for DOM referencescrollToBottom()function with smooth scrollingscrollToBottom()when adding new ruleagent-utility.svelte
Add scrolling to agent utility componentsrc/routes/page/agent/[agentId]/agent-components/agent-utility.svelte
scrollContainervariable for DOM referencescrollToBottom()function with smooth scrollingscrollToBottom()when adding new utility